package com.kuyu.wx;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.sql.Time;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;

/**
 * 编写一个定时任务
 */
@Component
public class TestTimer {
    private final SimpleDateFormat dateFormat=new SimpleDateFormat("HH:mm:ss");
    //token的有效时间为7200秒，我们每隔6000重新获取token
   /* @Scheduled(fixedRate = 1000*6)
    public void refershAccessToken(){
        //业务逻辑代码，获取公众号access_token
        System.out.println("现在时间"+dateFormat.format(new Date()));
    }*/
   /* public static void main(String[] args){
        new TestTimer(4);
    }
    public TestTimer(int second){
        Timer timer=new Timer();
        timer.schedule(new MyTimeTask(),0,second*1000);
    }

    private class MyTimeTask extends TimerTask{
        @Override
        public void run(){
            //业务逻辑代码
            System.out.println("定时任务运行");
        }
    }*/
}
